Magnetic field direction sensors can be used to measure orientation of a magnetic field generating object, such as a permanent magnet, with respect to a sensing axis of a magnetic field direction sensor. Thus, when the magnet is carried on a rotating object, such as a shaft whose position is to be encoded, the angular position of the shaft can be determined in a non-contacting manner. Such contactless operation can give excellent sensor longevity. Similarly the rate of rotation of a rotating object may also be determined by such a magnetic field direction sensor. There are many uses where it is desirable to know the rotational position of the shaft, for example to determine crank shaft position within an internal combustion engine.